<?php

namespace app\api\controller\v1;

use app\api\validate\IDCollection;
use app\api\validate\IDMustBePositiveInt;
use app\lib\exception\ThemeException;
use think\Controller;
use think\Request;
use app\api\model\Theme as ThemeModel;

class Theme extends Controller
{
    /**
     *  theme?ids=1,2,3
     * */
    public function getSimpleList($ids=''){
        (new IDCollection())->goCheck();
        $result = ThemeModel::getThemeList($ids);
        if ($result->isEmpty()){
            throw new ThemeException();
        }
        return $result;
    }
    /**
     * theme/id
     * */
    public function getComplexOne($id){
        (new IDMustBePositiveInt())->goCheck();
        $result = ThemeModel::getThemeWithProduct($id);
        if (!$result){
            throw new ThemeException();
        }
        $result->hidden(['products.summary']);
        return $result;
    }
}
